package com.seagox.chat.chat.controller;

import com.seagox.chat.chat.service.IChatMessageService;
import com.seagox.chat.common.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 聊天消息
 */
@RestController
@RequestMapping("/message")
public class ChatMessageController {

    @Autowired
    private IChatMessageService chatMessageService;

    /**
     * 分页获取聊天信息
     *
     * @param sessionId 会话id
     * @param userId 用户id
     * @param startTime 开始时间
     * @param typeStr 类型
     * @param content 内容
     * @return
     */
    @PostMapping("/queryByPage")
    public ResultData queryByPage(String sessionId, String userId, String startTime, String typeStr, String content) {
        return chatMessageService.queryByPage(sessionId, userId, startTime, typeStr, content);
    }
    
    @PostMapping("/deleteByMsgid")
    public ResultData deleteByMsgid(String msgid, String userId, String sessionId) {
        return chatMessageService.deleteByMsgid(msgid, userId, sessionId);
    }
    
    /**
     * 清空聊天记录
     */
    @PostMapping("/clear")
    public ResultData clear(String userId, String sessionId) {
        return chatMessageService.clear(userId, sessionId);
    }
    
    /**
     * 撤回
     */
    @PostMapping("/revoke")
    public ResultData revoke(String userId, String sessionId, String msgid) {
        return chatMessageService.revoke(userId, sessionId, msgid);
    }
    
    /**
     * 获取聊天信息(图片和视频)
     *
     * @param sessionId 会话id
     * @param userId 用户id
     * @param startTime 开始日期
     * @param endTime 结束日期
     * @return
     */
    @PostMapping("/queryPictureAndVideo")
    public ResultData queryPictureAndVideo(String sessionId, String userId, String startTime, String endTime) {
        return chatMessageService.queryPictureAndVideo(sessionId, userId, startTime, endTime);
    }
    
}

